<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            //保存按钮单击事件
            $("input[type='button']").click(function () {
                //获取表单数据
                var data = $("form").serialize();
                $.post("/person/update",data,function (result) {
                    if (result == 'success'){
                        alert("信息修改成功！");
                        location.href = "/person/toList";
                    }else{
                        alert("信息修改失败，请稍后再试！");
                        location.href = "/person/toList";
                    }
                })
            })
            $("#back").click(function () {
                history.back();
            })
        })
    </script>
</head>
<body>
<div align="center">
    <h2>修改员工信息</h2>
    <form>
        <table border="1" cellspacing="0" width="50%">
            <tr>
                <td>员工姓名：</td>
                <td>
                    <input type="text" name="name" th:value="${person.name}">
                    <input type="hidden" name="id" th:value="${person.id}">
                </td>
            </tr>
            <tr>
                <td>性别：</td>
                <td>
                    <select name="gender">
                        <option value="1" th:selected="${person.gender==1}">男</option>
                        <option value="0" th:selected="${person.gender==0}">女</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>年龄：</td>
                <td>
                    <input type="text" name="age" th:value="${person.age}">
                </td>
            </tr>
            <tr>
                <td>等级</td>
                <td>
                    <select name="rank">
                        <option value="1" th:selected="${person.rank==1}">1级</option>
                        <option value="2" th:selected="${person.rank==2}">2级</option>
                        <option value="3" th:selected="${person.rank==3}">3级</option>
                        <option value="4" th:selected="${person.rank==4}">4级</option>
                        <option value="5" th:selected="${person.rank==5}">5级</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td>部门：</td>
                <td>
                    <select name="department">
                        <option value="技术部" th:selected="${person.department=='技术部'}">技术部</option>
                        <option value="开发部" th:selected="${person.department=='开发部'}">开发部</option>
                        <option value="测试部" th:selected="${person.department=='测试部'}">测试部</option>
                        <option value="工程质量部" th:selected="${person.department=='工程质量部'}">工程质量部</option>
                    </select>
                </td>
            </tr>
            <tr align="center">
                <td colspan="2">
                    <input type="button" value="保存">
                </td>
            </tr>
        </table>
        <div align="center">
            <button type="button" id="back">返回</button>
        </div>
    </form>
</div>
</body>
</html>